package com.project.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.project.bean.UserBean;
import com.project.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("user")
public class UserController {
    @Autowired
    private IUserService service;

    @RequestMapping("findByItem")
    public IPage<UserBean> findByItem(int pageNo,String account){
        return service.findByItem(pageNo, account);
    }

    @RequestMapping("add")
    public String add(UserBean user,int[] roleArray){
        service.add(user, roleArray);
        return "ok";
    }

    @RequestMapping("findById")
    public UserBean findById(int id){
        return service.findById(id);
    }

    @RequestMapping("update")
    public String update(int userId,int[] roleArray){
        service.update(userId, roleArray);
        return "ok";
    }

    @RequestMapping("del")
    public String del(int id){
        service.del(id);
        return "ok";
    }
}
